#include<stdio.h>

int isLeapYear( int year) 
{
	int ret = 0;
	if ( (year%4 == 0 && year%100 != 0) || year % 400 == 0 )
	{
		ret = 1;
	}
	return ret;
}

int main()
{
	int year = 0;
	int month = 0;
	scanf("%d %d", &year, &month);
	int day = 0;
	switch(month)
	{
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		day = 31;
		break;
	case 2:
		day = 28;
		if ( isLeapYear(year) ) {
			day = 29;
		}
		break;
	case 4:	
	case 6:
	case 9:
	case 11:
		day = 30;
		break;
	}
	printf("%d", day);
	return 0;
}
